package net.mihome.app.bean;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * Created by ZHAO on 2015/1/31 0031.
 * 商品的bean
 */
public class Goods {
    private Integer id;
    private Double price;
    private String desc;
    private String name;
    private String img;
    private Object communityId;
    private String createAt;
    private String updateAt;
    private String unit;

    private Integer likeSum;
    private Integer trampleSum;
    private Integer buySum;
    private String phoneNum;

    public static Goods parse(Map map){
        if(map!=null){
            Goods goods=new Goods();
            Double idDouble= (Double) map.get("id");
            goods.setId(idDouble.intValue());
            goods.setPrice((Double) map.get("price"));
            goods.setDesc((String) map.get("desc"));
            goods.setUpdateAt((String) map.get("update_at"));
            goods.setCreateAt((String) map.get("create_at"));
            goods.setImg((String) map.get("img"));
            goods.setName((String) map.get("name"));
            goods.setUnit((String) map.get("unit"));
            goods.setCommunityId(map.get("community_id"));
            goods.setPhoneNum((String) map.get("phone_num"));
            Double likeSumDouble= (Double) map.get("like_sum");
            goods.setLikeSum(likeSumDouble.intValue());
            Double trampSumDouble= (Double) map.get("trample_sum");
            goods.setTrampleSum(trampSumDouble.intValue());
            Double buySumDouble= (Double) map.get("buy_sum");
            goods.setBuySum(buySumDouble.intValue());
            return goods;
        }else{
            return null;
        }
    }

    public String getPhoneNum() {
        return phoneNum;
    }

    public void setPhoneNum(String phoneNum) {
        this.phoneNum = phoneNum;
    }

    public static List<Goods> parseList(List<Map> maps){
        List<Goods> list=new ArrayList<>();
        if(maps!=null){
            Iterator<Map> iterator=maps.iterator();
            while(iterator.hasNext()){
                Map map=iterator.next();
                Goods goods=Goods.parse(map);
                list.add(goods);
            }
            return list;
        }else{
            return null;
        }
    }


    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }


    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getImg() {
        return img;
    }

    public void setImg(String img) {
        this.img = img;
    }


    public Object getCommunityId() {
        return communityId;
    }

    public void setCommunityId(Object communityId) {
        this.communityId = communityId;
    }

    public String getCreateAt() {
        return createAt;
    }

    public void setCreateAt(String createAt) {
        this.createAt = createAt;
    }

    public String getUpdateAt() {
        return updateAt;
    }

    public void setUpdateAt(String updateAt) {
        this.updateAt = updateAt;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public Integer getLikeSum() {
        return likeSum;
    }

    public void setLikeSum(Integer likeSum) {
        this.likeSum = likeSum;
    }

    public Integer getTrampleSum() {
        return trampleSum;
    }

    public void setTrampleSum(Integer trampleSum) {
        this.trampleSum = trampleSum;
    }

    public Integer getBuySum() {
        return buySum;
    }

    public void setBuySum(Integer buySum) {
        this.buySum = buySum;
    }
}
